// OptionsDialog.cpp : implementation file
//

#include "stdafx.h"
#include "UIEditor_CPP.h"
#include "OptionsDialog.h"
#include "afxdialogex.h"
#include "config.h"


// COptionsDialog dialog

IMPLEMENT_DYNAMIC(COptionsDialog, CDialog)

COptionsDialog::COptionsDialog(CWnd* pParent /*=NULL*/)
	: CDialog(COptionsDialog::IDD, pParent)
	, m_strBaseDir(_T(""))
{

}

COptionsDialog::~COptionsDialog()
{
}

void COptionsDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT_BASE_DIR, m_strBaseDir);
}


BEGIN_MESSAGE_MAP(COptionsDialog, CDialog)
	ON_BN_CLICKED(IDOK, &COptionsDialog::OnBnClickedOk)
END_MESSAGE_MAP()


// COptionsDialog message handlers


void COptionsDialog::OnBnClickedOk()
{
	UpdateData();
	config::instance().m_strBaseDir = m_strBaseDir.GetBuffer();
	theApp.WriteProfileString(L"dir", L"base dir", m_strBaseDir);
	CDialog::OnOK();
}


BOOL COptionsDialog::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  Add extra initialization here
	m_strBaseDir = theApp.GetProfileStringW(L"dir", L"base dir");

	UpdateData(FALSE);
	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
